package net.hn.hnms.biz.shipped.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.hn.hnms.biz.shipped.request.TransportDeliveryInfoReq;
import net.hn.hnms.biz.shipped.request.TransportDeliveryStatisticsReq;
import net.hn.hnms.biz.shipped.service.ITransportDeliveryInfoService;
import net.hn.hnms.biz.shipped.service.ITransportDeliveryStatisticsService;
import net.hn.hnms.biz.shipped.vo.TransportDeliveryInfoVO;
import net.hn.hnms.biz.shipped.vo.TransportDeliveryStatisticsVO;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.core.web.controller.BaseController;
import net.hn.hnms.sys.common.log.annotation.Log;
import net.hn.hnms.sys.common.log.enums.BusinessType;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author Wang Jingrui
 * @date 2022/8/24 14:28
 */
@Api(value = "发运管理模块", tags = {"发运管理模块"})
@RestController
@RequestMapping("/transport")
public class TransportController extends BaseController {

    @Autowired
    private ITransportDeliveryInfoService transportDeliveryInfoService;

    @Autowired
    private ITransportDeliveryStatisticsService transportDeliveryStatisticsService;

    /**
     * 发运统计
     */
    @ApiOperation("发运统计")
//    @SaCheckPermission("transport:statistics:page")
    @GetMapping("/statistics/page")
    @AutoSetMineCode
    public R<ResponsePage<TransportDeliveryStatisticsVO>> page(TransportDeliveryStatisticsReq req, PageQuery pageQuery) {
        return R.ok(transportDeliveryStatisticsService.selectPageList(req, pageQuery));
    }
    /**
     * 发运流水
     */
    @ApiOperation("发运流水")
//    @SaCheckPermission("transport:info:page")
    @GetMapping("/info/page")
    @AutoSetMineCode
    public R<ResponsePage<TransportDeliveryInfoVO>> page(TransportDeliveryInfoReq req, PageQuery pageQuery) {
        return R.ok(transportDeliveryInfoService.selectPageList(req, pageQuery));
    }
    /**
     * 下拉框
     */
    @ApiOperation("下拉框")
//    @SaCheckPermission("transport:info:page")
    @GetMapping("/record/dict/list")
    @AutoSetMineCode
    public R<List<Map<String, Object>>> dictListRec(@ApiParam(value = "煤矿编码") String mineCode) {
        return R.ok(transportDeliveryInfoService.dictList(mineCode));
    }
    /**
     * 下拉框
     */
    @ApiOperation("下拉框")
//    @SaCheckPermission("transport:info:page")
    @GetMapping("/statistics/dict/list")
    public R<List<Map<String, Object>>> dictListSat(@ApiParam(value = "煤矿编码") String mineCode) {
        return R.ok(transportDeliveryStatisticsService.dictList(mineCode));
    }


    @ApiOperation("发运统计数据导入")
    @SaCheckPermission("transport:shippingStatisticsImport")
    @PostMapping("/shippingStatisticsImport")
    @Log(title = "发运统计数据导入", businessType = BusinessType.IMPORT)
    public R<Void> shippingStatisticsImport(@RequestPart MultipartFile file)  {
        transportDeliveryStatisticsService.shippingStatisticsImport(file);
        return R.ok();
    }

    @ApiOperation("发运流水数据导入")
//    @SaCheckPermission("transport:shippingInfoImport")
    @PostMapping("/shippingInfoImport")
    @AutoSetMineCode
    @Log(title = "发运统计数据导入", businessType = BusinessType.IMPORT)
    public R<Void> shippingInfoImport(@RequestPart MultipartFile file)  {
        transportDeliveryStatisticsService.shippingInfoImport(file);
        return R.ok();
    }
}
